package org.example;
import java.util.HashSet;
import java.util.Set;

public class UserDao1 {
    Set<User1> user1Set;
    public UserDao1(){
        user1Set = new HashSet<>();
    }
    public Set<User1> getAll(){
        return new HashSet<>(user1Set);
    }
    //新增
    public boolean add(User1 user1){
        user1Set.add(user1);
        return true;
    }
    //删除
    public boolean delete(User1 user1){
        user1Set.remove(user1);
        return true;
    }
    //修改
    public boolean update(User1 user1){
        for (User1 item : user1Set){
            if (user1.getId()==item.getId()){
                item.setName(user1.getName());
            }
        }
        return true;
    }
}
